package com.panopset;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * Provide some feedback from an exec function.
 *
 * @author Karl Dinwiddie
 *
 */
public final class Commander {

    /**
     * Execute a command.
     *
     * @param cmd
     *            a specified system command.
     */
    public void exec(final String cmd) {
        if (Util.isVerbose()) {
            System.out.println("Executing command:");
            System.out.println(cmd);
        }
        try {
            Process p = Runtime.getRuntime().exec(cmd);
            String s = "";
            BufferedReader input = new BufferedReader(new InputStreamReader(
                    p.getInputStream()));
            while ((s = input.readLine()) != null) {
                System.out.println(s);
            }
            input.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
